import 'package:flutter_demo/core/common/model/ui_element_model.dart';

class CreativeModel {
  String? creativeType;
  String? creativeId;
  String? action;
  String? actionType;
  UiElementModel? uiElement;
  List<Resources>? resources;
  String? alg;
  String? logInfo;
  int? position;

  CreativeModel(
      {this.creativeType,
      this.creativeId,
      this.action,
      this.actionType,
      this.uiElement,
      this.resources,
      this.alg,
      this.logInfo,
      this.position});

  CreativeModel.fromJson(Map<String, dynamic> json) {
    creativeType = json['creativeType'];
    creativeId = json['creativeId'];
    action = json['action'];
    actionType = json['actionType'];
    uiElement = json['uiElement'] != null
        ? new UiElementModel.fromJson(json['uiElement'])
        : null;
    if (json['resources'] != null) {
      resources = <Resources>[];
      json['resources'].forEach((v) {
        resources!.add(new Resources.fromJson(v));
      });
    }
    alg = json['alg'];
    logInfo = json['logInfo'];
    position = json['position'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['creativeType'] = this.creativeType;
    data['creativeId'] = this.creativeId;
    data['action'] = this.action;
    data['actionType'] = this.actionType;
    if (this.uiElement != null) {
      data['uiElement'] = this.uiElement!.toJson();
    }
    if (this.resources != null) {
      data['resources'] = this.resources!.map((v) => v.toJson()).toList();
    }
    data['alg'] = this.alg;
    data['logInfo'] = this.logInfo;
    data['position'] = this.position;
    return data;
  }
}

class Resources {
  UiElementModel? uiElement;
  String? resourceType;
  Null? resourceState;
  String? resourceId;
  Null? resourceUrl;
  dynamic resourceExtInfo;
  String? action;
  String? actionType;
  bool? valid;
  String? alg;
  String? logInfo;
  Null? ctrp;
  Null? likedCount;
  Null? replyCount;
  Null? resourceContentList;
  Null? position;
  Null? playParams;

  Resources(
      {this.uiElement,
      this.resourceType,
      this.resourceState,
      this.resourceId,
      this.resourceUrl,
      this.resourceExtInfo,
      this.action,
      this.actionType,
      this.valid,
      this.alg,
      this.logInfo,
      this.ctrp,
      this.likedCount,
      this.replyCount,
      this.resourceContentList,
      this.position,
      this.playParams});

  Resources.fromJson(Map<String, dynamic> json) {
    uiElement = json['uiElement'] != null
        ? new UiElementModel.fromJson(json['uiElement'])
        : null;
    resourceType = json['resourceType'];
    resourceState = json['resourceState'];
    resourceId = json['resourceId'];
    resourceUrl = json['resourceUrl'];
    resourceExtInfo = json['resourceExtInfo'] != null
        ? new ResourceExtInfoModel.fromJson(json['resourceExtInfo'])
        : null;
    action = json['action'];
    actionType = json['actionType'];
    valid = json['valid'];
    alg = json['alg'];
    logInfo = json['logInfo'];
    ctrp = json['ctrp'];
    likedCount = json['likedCount'];
    replyCount = json['replyCount'];
    resourceContentList = json['resourceContentList'];
    position = json['position'];
    playParams = json['playParams'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.uiElement != null) {
      data['uiElement'] = this.uiElement!.toJson();
    }
    data['resourceType'] = this.resourceType;
    data['resourceState'] = this.resourceState;
    data['resourceId'] = this.resourceId;
    data['resourceUrl'] = this.resourceUrl;
    if (this.resourceExtInfo != null) {
      data['resourceExtInfo'] = this.resourceExtInfo!.toJson();
    }
    data['action'] = this.action;
    data['actionType'] = this.actionType;
    data['valid'] = this.valid;
    data['alg'] = this.alg;
    data['logInfo'] = this.logInfo;
    data['ctrp'] = this.ctrp;
    data['likedCount'] = this.likedCount;
    data['replyCount'] = this.replyCount;
    data['resourceContentList'] = this.resourceContentList;
    data['position'] = this.position;
    data['playParams'] = this.playParams;
    return data;
  }
}

class ResourceExtInfoModel {
  int? playCount;
  bool? highQuality;
  int? specialType;

  ResourceExtInfoModel({this.playCount, this.highQuality, this.specialType});

  ResourceExtInfoModel.fromJson(Map<String, dynamic> json) {
    playCount = json['playCount'];
    highQuality = json['highQuality'];
    specialType = json['specialType'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['playCount'] = this.playCount;
    data['highQuality'] = this.highQuality;
    data['specialType'] = this.specialType;
    return data;
  }
}
